<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>麦知网——学问有余，可为人师</title>

<!-- Bootstrap core CSS -->
<link href="../../../../css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="../../../../css/non-responsive.css" rel="stylesheet">
<link href="../../../../css/font-awesome.min.css" rel="stylesheet">
<link href="../../../../css/theCourse.css" rel="stylesheet"> 	
<link href="../../../../css/manageCourse.css" rel="stylesheet"> 
<link href="../../../../css/sco.message.css" rel="stylesheet">
<link href="../../../../css/scojs.css" rel="stylesheet">
<link href="../../../../css/bootstrap-switch.css" rel="stylesheet">
</head>
<body>
	{% include 'public/common/header.html' %}
	<div class="container" style="margin-top:45px">
		<div class="row">
			<div class="col-xs-12">
				{% if type %}
				<div>
					<ol class="breadcrumb tc_breadcrumb">
					  <li><a href="{% url 'courses:types' %}">课程系列</a></li>
					  <li><a href="{% url 'courses:tinytypes' type.id %}">{{type.name}}</a></li>
					  <li><a href="{% url 'courses:courselist' tiny.id %}">{{tiny.name}}</a></li>
					  <li class="active">{{course.name}}</li>
					</ol>
				</div>
				{% endif %}
				<div class="tc_topDiv">
					<div class="pull-left tc_topDiv1">
						<div>
							<img src="{{course.domain}}/{{course.img}}" width="100%"/>
						</div>
<!-- 只有老师有  开始
					{% ifequal limit '1' %}
						<div class="change_img"><a id="change_img" href="#" data-toggle="popover" data-placement="bottom" data-content="<div>请选择180×180<form action='{% url 'courses:update' course.id %}' method='post' enctype='multipart/form-data'>{% csrf_token %}<div><input type='file' name='courseImg'></div><div style='margin-top:15px;text-align:center'><input type='submit' value='确认修改'></div></form></div>" data-original-title title>修改图片</a></div>
					{% endifequal %}-->
<!-- 只有老师有   结束 -->
					</div>
					<div class="pull-left tc_topDiv2">
						<div>
							<div class="cl_a_course_right1">
								<div class="pull-left cl_course_name"><b id="coursename">{{course.name}}</b></div>
								<div class="pull-left">
<!-- 用星星评价的地方    第一个span是黄色星星  第二个span是空心星星  分别循环   -->
									<span id='coursegrade'></span>
									<script>
										for (var i=1;i<={{course.grade}};i++){
											document.getElementById('coursegrade').innerHTML+="<span class='yellow_star'>&#9733</span>";
										}
										for (var j=5;j>{{course.grade}};j--){
											document.getElementById('coursegrade').innerHTML+="<span class='star'>☆</span>";
										}
									</script>
								
<!-- 用星星评价的地方 结束 -->							
								</div>

								
								{% if price %}
								<div class="pull-left price"><span class="badge badge2">{{price}}</span></div>
								{% else %}
								<div class="pull-left cl_font">（{{course.grade_con}}人评价）</div>
								<div class="pull-left cl_font">{{course.purchase_con}}人购买</div>
								<div class="pull-left price"><span class="badge badge2">{% ifequal course.price 0 %}免费{% else %}￥{{course.price}}{% endifequal %}</span></div>
								{% endif %}
								<div class="pull-right">
<!-- 老师  只有这1个button -->	
								{% ifequal limit '1' %}
									{% ifequal course.over 0 %}
										{% ifequal s 1 %}
										<a type="button" href="/courses/types/tiny/course/lession/add/{{course.id}}?method=1" class="btn btn-warning tc_btn_intro">添加课时</a>
										<input type="hidden" value='1' id="hidemethod" />
										{% endifequal %}
										{% ifequal s 0 %}
										<a type="button" href="{% url 'courses:addlession' course.id %}" class="btn btn-warning tc_btn_intro">添加课时</a>
										<input type="hidden" value='0' id="hidemethod" />
										{% endifequal %}
									{% endifequal %}
									{% ifequal course.over 0 %}
									<a type="button" id="unfinal" href="{% url 'courses:addlession' course.id %}" class="btn btn-success tc_btn_intro">课程未完结</a>
									<a type="button" style="display:none" href="{% url 'courses:addlession' course.id %}" class="btn btn-danger tc_btn_intro" id="over">课程已完结</a>
									<a href="javascript:void(0)" data-toggle="modal" data-target="#myModal">完结课程</a>
									{% else %}
									<a type="button" href="{% url 'courses:addlession' course.id %}" class="btn btn-danger tc_btn_intro">课程已完结</a>
									{% endifequal %}
								{% endifequal %}
<!-- 其他用户  只有这两个button -->				{% ifequal limit '4' %}
									<a type="button" href="{% url 'courses:purchase' course.id %}" class="btn btn-warning tc_btn_intro">购买</a>
								{% endifequal %}
								{% ifequal limit '3' %}
									<button type="button" class="btn btn-warning tc_btn_intro">去付款</button>
									{% ifequal course.over 0 %}
									<a type="button" href="{% url 'courses:addlession' course.id %}" class="btn btn-success tc_btn_intro">课程未完结</a>
									{% else %}
									<a type="button" href="{% url 'courses:addlession' course.id %}" class="btn btn-danger tc_btn_intro">课程已完结</a>
									{% endifequal %}
								{% endifequal %}
								{% ifequal limit '2' %}
									<button type="button" class="btn btn-warning tc_btn_intro">已购买</button>
									{% ifequal course.over 0 %}
									<button type="button" class="btn btn-success tc_btn_intro">课程未完结</button>
									{% else %}
									<a type="button" href="{% url 'courses:addlession' course.id %}" class="btn btn-danger tc_btn_intro">课程已完结</a>
									{% endifequal %}
								{% endifequal %}
								{% if price %}

								{% else %}
								{% ifnotequal limit '1' %}
								{% ifequal collect '1' %}
									<input type="button" class="btn btn-info tc_btn_intro" value="已收藏" />
								{% else %}
									<input type="button" class="btn btn-info tc_btn_intro" id="collection" onclick="collect({{course.id}})" value="收藏" />
								{% endifequal %}
								{% endifnotequal %}
								{% endif %}
								</div>
								<div class="clearfix"></div>
							</div>
						</div>
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						  <div class="modal-dialog">
						    <div class="modal-content">
						      <div class="modal-header">
						        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						        <h4 class="modal-title" id="myModalLabel">您确定要完结课程么？(完结后不可以再上传课程)</h4>
						      </div>
						      <div class="modal-footer" style="border:0px solid white;">
						        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						        <button type="button" class="btn btn-success" onclick="finish({{course.id}})">确定完结</button>
						      </div>
						    </div><!-- /.modal-content -->
						  </div><!-- /.modal-dialog -->
						</div><!-- /.modal -->
<!-- 只有老师有  开始-->
					{% ifequal limit '1' %}
						<div class="change_title"><a id="change_title" href="javascript:void(0)" data-toggle="popover" data-placement="bottom" data-content="<div><div><input type='text' id='name' maxlength='15' style='resize:none;width:200px;' /></div><div style='margin-top:15px;text-align:center'><a href='javascript:void(0)' type='button' onclick='changename({{course.id}})' class='btn btn-default btn-xs'>确认修改</a></div></div>" data-original-title title>修改课程名</a></div>
					{% endifequal %}
<!-- 只有老师有   结束 -->
						
						<!--{% if messages %}  
							<ul class="messages">  
							    {% for message in messages %}  
							    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>  
							    {% endfor %}  
							</ul>  
						{% endif %}  -->

						<div class="tc_introduce"><i id="courseintro">
<!-- 此处课程介绍需要由后台截断字符串 -->
							{{course.introduce}}
						</i></div>
						<div class="tc_share">
							{% ifequal limit '1' %}
							<div class="pull-left">
								<div class="change_intro"><a id="change_intro" href="javascript:void(0)" data-toggle="popover" data-placement="bottom" data-content="<div><div><textarea style='resize:none;width:200px;' id='intro'></textarea></div><div style='margin-top:15px;text-align:center'><a href='javascript:void(0)' onclick='changeintro({{course.id}})' type='button' class='btn btn-default btn-xs'>确认修改</a></div></div>" data-original-title title>修改课程介绍</a></div>
							</div>
							{% endifequal %}
							{% if price %}

							{% else %}
							<div class="pull-right">
								<!-- JiaThis Button BEGIN -->
								分享到：
								<div class="jiathis_style">
									<a class="jiathis_button_qzone"></a>
									<a class="jiathis_button_tsina"></a>
									<a class="jiathis_button_tqq"></a>
									<a class="jiathis_button_weixin"></a>
									<a class="jiathis_button_renren"></a>
									<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
									<a class="jiathis_counter_style"></a>
								</div>
								<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
								<!-- JiaThis Button END -->
							</div>
							{% endif %}
							<div class="clearfix"></div>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-3 row2_col">
<!-- 举报 -->
				<div style="width:100%;margin-top:20px;padding-bottom:20px;">
					<button type="button" class="btn btn-danger btn-small" style="
					width:100%;" data-toggle="modal" data-target="#bad_any">举报本课程</button>

					<div class="modal fade" id="bad_any" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					  <div class="modal-dialog">
					    <div class="modal-content">
					      <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					        <h4 class="modal-title">举报原因</h4>
					      </div>
					      <div class="modal-body">
					        <textarea class="form-control" id="bad_content" style="height:120px;resize:none;"></textarea>
					      </div>
					      <div class="modal-footer">
					      	
					        <button type="button" onclick="bad_send({{c_id}},3);" class="btn btn-primary">举报</button>
					      </div>
					    </div><!-- /.modal-content -->
					  </div><!-- /.modal-dialog -->
					</div><!-- /.modal -->
				</div>
<!-- 举报结束 -->
				<div class="tc_teacher_intro">
					<div>
						<div class="pull-left tc_tea_img">
							<img src="{{tinfo.domain}}/{{tinfo.img}}" class="img-circle" width="100%"/>
						</div>
						<div class="pull-left tc_tea_name">
							<div style="margin-bottom:10px;margin-top:10px"><b><a href="{% url 'users:home' tinfo.user_id %}">{{tinfo.user_name}}</a></b>{% ifequal purview '1' %}<i class="icon-check" title="认证用户" style="margin-left:7px"></i>{% endifequal %}{% ifequal purview '2' %}<i class="icon-home" title="企业用户" style="margin-left:7px"></i>{% endifequal %}</div>
							<div id="course_left_user">
								{% ifequal focus '0' %}
								<button type="button" class="btn btn-success btn-xs" onclick="add({{course.teacher_id}});">关注</button>
								<!--<div class="switchDiv">
									<div class="switch switch-small" data-on="info" data-off="NO">	
										<input type="checkbox" checked="checked" onchange="add({{course.teacher_id}})"/> 
									</div>
								</div>-->
								{% endifequal %}
								{% ifequal focus '1' %}
								<font size="1" color="#333333">已关注</font>
								<!--<div class="switchDiv">
									<div class="switch switch-small" data-on="info" data-off="NO">	
										<input type="checkbox" onchange="add({{course.teacher_id}})" />
									</div>
								</div>-->
								{% endifequal %}
							</div>
							{% ifequal focus '3' %}
									<div><span class="person_name"><a href=""><b>{{u.0}}</b></a></span><span class="focus"><button type="button" class="btn btn-success btn-xs">我的课程</button></span></div>
							{% endifequal %}
						</div>
						<div class="clearfix"></div>
					</div>
					<div style="margin:3px 9px 3px 9px"><i class="icon-edit" style="margin-right:5px"></i>{{tinfo.introduce}}</div>
				</div>
			</div>
			<div class="col-xs-9 row2_col">
				<div>
					<div class="tab_left">
						<ul class="nav nav-tabs">
						  <li class="active"><a href="#purchase" data-toggle="tab">课时</a></li>
						  <li><a href="#collect" data-toggle="tab">课程评价</a></li>
						</ul>
					</div>
				</div>
<!-- Tab panes -->
				<div class="tab-content">
<!-- 课时 标签第一签 -->
					<div class="tab-pane active" id="purchase">
						<div>
							<table class="table table-hover" id="table">
								<tbody>
<!-- 一条课时  循环开始处 -->
								{% for i in lession %}
									<tr>
										<td class="td12" style="border-top-style: none;">
											<span class="glyphicon glyphicon-play-circle"  style="margin-right:20px"></span>
											课时{{i.lession_no}}：
											<a href="{% url 'courses:play' i.id %}" title="{{i.name}}">{{i.name}}</a>
										</td>
									</tr>
								{% endfor %}
<!-- 一条课时  循环结束处 -->
								</tbody>
							</table>
						</div>
					</div>
<!-- 课程评价  标签第二签 -->
					<div class="tab-pane" id="collect">
					{% ifequal review '1' %}
						您已经评价过
					{% else %}
						<div id="change_content">
						您尚未评价本课程，您可以<a id="score" href="javascript:void(0)" data-toggle="popover" data-placement="bottom" data-content="<div>课程打分：<span class='rating' id='rate'><span class='star' onclick='star(5);' style='width:20px;'>☆</span><span class='star' onclick='star(4);' style='width:20px;'>☆</span><span class='star' onclick='star(3);' style='width:20px;'>☆</span><span class='star' onclick='star(2);' style='width:20px;'>☆</span><span class='star' onclick='star(1);' style='width:20px;'>☆</span></span></div><div><span class='score_text1'>课程评价：</span><textarea class='score_text' id='commentInfo'></textarea></div><div class='intro_btn'><button type='button' onclick='comment({{course.id}})' class='btn btn-warning btn-xs'>添加评价</button></div>" data-original-title title>评价</a>
						</div>

		 <!--				 <div id="disqus_thread"></div>

   
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'trooon'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
	-->
						<div id="tc_commentt" class="tc_commit"></div>
					{% endifequal %}
<!-- 一条课程评价   循环开始处 -->
					{% for i in discuss %}
						<div class="tc_commit">
							<div class="pull-left tc_commit1">
								<div><img src=" {{i.6}}/{{i.1}}" width="100%"/></div>
							</div>
							<div class="pull-left tc_commit2">
								<div class="topdirection pull-left"></div>
								<div class="pull-left tc_commit32">
									<div>
<!-- 用星星评价的地方    第一个span是黄色星星  第二个span是空心星星  分别循环   -->
										<span id="grade{{i.5}}"></span>
									<script>
										for (var i=1;i<={{i.3}};i++){
											document.getElementById('grade{{i.5}}').innerHTML+="<span class='yellow_star'>&#9733</span>";
										}
										for (var j=5;j>{{i.3}};j--){
											document.getElementById('grade{{i.5}}').innerHTML+="<span class='star'>☆</span>";
										}
									</script>
<!-- 用星星评价的地方 结束 -->				
										<span class="tc_commit_name"><a href="{% url 'users:home' i.7 %}">{{i.0}}</a></span>
										<span class="tc_time">{{i.4|date:"Y-m-d H:i:s"}}</span>
									</div>
									<div class="tc_commit_content">{{i.2}}</div>
								</div>
							</div>
							<div class="clearfix"></div>
						</div>
					{% endfor %}
<!-- 一条课程评价   循环结束处 -->
					</div>
				</div>
			</div>
	</div>
	
	
	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->

<script src="../../../../js/jquery.min.js"></script>
<script src="../../../../js/course.js"></script>	
<script src="../../../../js/logout.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="../../../../js/bootstrap.js"></script>	
<script src="../../../../js/sco.message.js"></script>
<script src="../../../../js/bootstrap-switch-2.js"></script>
<script src="../../../../js/bad.js"></script>
<script type="text/javascript">
$('#change_img').popover({html:true});
$('#change_title').popover({html:true});
$('#change_intro').popover({html:true});	
$('#score').popover({html:true});
var xmlHttp; 

function createXMLRequest(){
	if(window.ActiveXObject){
		xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
	} else if(window.XMLHttpRequest){
		xmlHttp=new XMLHttpRequest();
	}
}

//添加关注
function add(u_id){   
	createXMLRequest();                       
	var url="/users/add/?id="+u_id;
	xmlHttp.open("GET",url);
	//var this_btn=document.getElementById('add'+u_id)
	//var that_btn=document.getElementById('abord'+u_id)
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			if(xmlHttp.responseText==1){
				$("#course_left_user").html('<font size="1" color="#333333">已关注</font>');
			}
		}
	};
	xmlHttp.send(); 
}


//完结课程系列
function finish(course){
	createXMLRequest();  
	method=document.getElementById('hidemethod').value                  
	var url="/courses/types/tiny/course/lession/finish/?course="+course+"&method="+method;
	xmlHttp.open("GET",url);
	var this_btn=document.getElementById('unfinal')
	var that_btn=document.getElementById('over')
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			if(xmlHttp.responseText==1){
				this_btn.style.display='none';
				that_btn.style.display='inline';
			}
		}
	};
	xmlHttp.send(); 
}

//课程评价
function comment(course){
	createXMLRequest();                      
	var commentInfo=document.getElementById('commentInfo').value;
	var url="/courses/types/tiny/course/lession/comment/?course="+course+"&star="+starCount+"&content="+commentInfo;
	xmlHttp.open("GET",url);
	xmlHttp.onreadystatechange=function(e){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			return_array=xmlHttp.responseText.split(',');//alert(starCount);
			var str1='<div class="pull-left tc_commit1"><div><img src="http://mzhead.qiniudn.com/'+return_array[2]+'" width="100%"/></div></div><div class="pull-left tc_commit2"><div class="topdirection pull-left"></div>';
			var str2='<div class="pull-left tc_commit32"><div><span id="gradehehe"></span>';
			var str3='<span class="tc_commit_name"><a href="">'+return_array[1]+'</a></span><span class="tc_time">刚刚更新</span></div>';
			var str4='<div class="tc_commit_content">'+commentInfo+'</div></div></div><div class="clearfix"></div>';
			var strr=str1+str2+str3+str4;
			 
			if(return_array[0]==1){
				$("#score").popover('toggle');
				//$("#collect").html('<div style="padding-bottom:20px;">您已经评价过</div>'+strr);
				$("#tc_commentt").html(strr);
				$("#change_content").html('您已经评价过');
				for (var i=1;i<=starCount;i++){
					document.getElementById('gradehehe').innerHTML+="<span class='yellow_star'>&#9733</span>";
				}
				for (var j=5;j>starCount;j--){
					document.getElementById('gradehehe').innerHTML+="<span class='star'>☆</span>";
				}


				e.preventDefault();
		    	$.scojs_message('您评论成功！', $.scojs_message.TYPE_OK);
		    	
			} else {
				e.preventDefault();
    			$.scojs_message('服务器出错啦～ ：）', $.scojs_message.TYPE_ERROR);
			}
		}
	};
	xmlHttp.send(); 
}
//课程评分
var starCount=0;

function star(integ){
	starCount=integ
	document.getElementById('rate').innerHTML=""
	for (var j=5;j>integ;j--) {
		document.getElementById('rate').innerHTML+="<span class='star' onclick='star("+j+")' style='width:20px'>☆</span>";
	}
	for (var i=1;i<=integ;i++) {
		document.getElementById('rate').innerHTML+="<span class='yellow_star' onclick='star("+parseInt(integ+1-i)+")' style='width:20px'>★</span>";
	}
}

//课程收藏
function collect(course){
	createXMLRequest();                      
	var url="/courses/types/tiny/course/lession/collect/?course="+course;
	xmlHttp.open("GET",url);
	xmlHttp.onreadystatechange=function(e){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			if(xmlHttp.responseText==1){
				e.preventDefault();
		    	$.scojs_message('您收藏成功！', $.scojs_message.TYPE_OK);
		    	document.getElementById('collection').value='已收藏'
			} else {
				e.preventDefault();
    			$.scojs_message('服务器出错啦～ ：）', $.scojs_message.TYPE_ERROR);
			}
		}
	};
	xmlHttp.send(); 
}
//window.onload=function(){
//	document.getElementById('table').rows[0].frame="below"
//}
</script>

</body>
</html>